/* 
 *  <copyright file="BaseMapper.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;
using SobrietyEngine.Events;
using SobrietyEngine.Events.Input;
using SobrietyEngine.Guids;
using SobrietyEngine.User;

namespace SobrietyEngine.Input.Mapping
{
    public abstract class BaseMapper : IInputMapper, IEventListener
    {
        public IEventRouter EventRouter { get; set; }
        public CGuid Owner { get; set; }
        public Boolean Enabled { get; set; }

        public BaseMapper(IEventRouter er, CGuid owner)
        {
            EventRouter = er;
            Owner = owner;
            Enabled = false;
        }

        public Boolean IsInputMine(Event e)
        {
            IInputEvent ie = (IInputEvent)e.Data;

            IUser owner = (IUser)Owner.Resolve();

            if(owner.InputDevices.Contains(ie.InputDevice))
                return true;

            return false;
        }
    
        public string  GetEventType()
        {
 	        throw new NotImplementedException();
        }        

        abstract public void RegisterEventListeners();
        abstract public void UnregisterEventListeners();
        abstract public void HandleEvent(Event e);
}
}
